import React, {Component} from "react";
import BeeGrid,{GridToolBar}  from "bee-complex-grid";
import {Table,Checkbox} from 'tinper-bee';
import sum from "bee-table/build/lib/sum.js";
import multiSelect from "bee-table/build/lib/multiSelect.js";
let ComplexTable = multiSelect(sum(Table), Checkbox);

const defaultProps = {
    headerScroll: false,
    bordered: false,
    data: []
};

class Grid extends Component {
    constructor(props) {
        super(props);
    }
    exportExcel=()=>{
        this.grid.exportExcel();
    }
    render() {
        const { paginationObj, data,sumTableFlag,  ...otherProps } = this.props;
        if(sumTableFlag) {
            return (
                <ComplexTable
                    {...otherProps}
                    className="ac-grids"
                    data={data}
                    paginationObj='none'
                    // defaultExpandAllRows={true}
                    columnFilterAble={false}
                    ref={ref=>this.grid=ref}
                    syncHover={false}
                />
            
            )
        }else {
            return (
                <BeeGrid
                    {...otherProps}
                    className="ucf-example-grid"
                    data={data}
                    paginationObj={paginationObj || 'none'}
                    columnFilterAble={false}
                    ref={ref=>this.grid=ref}
                    syncHover={false}
                />
            );
        }
    }
}

Grid.defaultProps = defaultProps;
Grid.GridToolBar = GridToolBar;
export default Grid;
